#ifndef __Field__ 
#define __Field__

#include "shape.h"
#include "texture.h"
#include "peak.h"
#include "rain.h"
#include "material.h"

#include <algorithm>

#define PI 3.14159265
using namespace std;

class Field {
private:
	vector<vector<Peak> > hmap;
	vector<vector<Rain> > w_hmap;
	Vector a; //bas gauche de la boite englobante
	Vector b; //haut droit de la boite englobante 
	int size;
	double lx;
	double ly;
	vector<Material> slices;
public:
	Field();
	Field(int size, double amplitude, vector<Material> slices);
	Field(const Vector& a,const Vector& b,int n, vector<Material> slices);

	inline double h(int i, int j);
	inline void seth(int i, int j, double h, int mat);
	inline Vector Vertex(int i, int j);
	inline Vector PlaneVertex(int i, int j);

	void Generate();
	void Render();

	void showNode();

	double Noise(Texture T, int mat);

	void thermalErosion(double descentLimit);
	void spread(int i, int j);

	void hydroErosion();
	void initW_hmap(double w_height);

	Vector colorLevel(int i, int j);

	// -------Fractal
	//void Fractal();
	//double Middle(double a, double b, double c, double d, int k);
	//double Middle(double a, double b, double c, int k);
	//double rand_fonct(int k);
	//double guauss_fonct(double x, double s, double u);
	//--------------

};

#endif